<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文件</title>
<link href="__CSS__public.css" rel="stylesheet" type="text/css" />
<script src="__JS__jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="__JS__jquery.validate.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
    var hrf='{:U("Admin/index/")}';
$(document).ready(function(){
	var validator = $('#adminlogin').validate({
		submitHandler: function() {
			$.ajax({
				type:'POST',
				url:'__URL__/chkLogin',
				data:{
					username: $("#username").val(),
					password: $("#password").val(),
					verify: $("#verify").val(),
				},
				dataType:'JSON',
				cache:false,
				success:function(data){
					if (data=="") {
						
						$('.login legend').html("登陆成功！");
						$('.login p').remove();
						$('.login').append('<p style="text-align:center;line-height:120px;">2秒后会自动进入！</p>');
						setTimeout(function(){window.location.href=hrf}, 2000);
					} else {
						$('#label').html(data);
					}
				},
			});
		},
		rules: {
			username: {
				required: true,
				minlength: 6,
			},
			password: {
				required: true,
				minlength: 6,
			},
			verify: {
				required: true,
			},
		},
		messages: {
			username: {
				required: "请输入用户名",
				minlength: jQuery.format("最少{0}位字符"),
			},
			password: {
				required: "请输入密码",
				minlength: jQuery.format("最少{0}位字符"),
			},
			verify: {
				required: "请输入验证码",
			},
		},
	});
});

function fleshVerify(type) { 
	//重载验证码
	var timenow = new Date().getTime();
	if (type) {
		$('#verifyImg').attr('src', '{:U("Admin/verify?adv=1")}'+timenow);
	} else {
		$('#verifyImg').attr('src', '{:U("Admin/verify/")}'+timenow);
	}
}
</script>
<form id="adminlogin" method="post">
  <fieldset class="login">
    <legend>网站后台管理员登陆</legend>
    <p id="label"></p>
    <p>
      <label>管理员名称</label>
      <input id="username" name="username" type="text" />
      <span class="status"></span> </p>
    <p>
      <label>管理员密码</label>
      <input id="password" name="password" type="password" />
      <span class="status"></span> </p>
    <p>
      <label>验证码</label>
      <input id="verify" name="verify" type="text" maxlength="4" style="width:30px;font-family:Courier New" />
      <img id="verifyImg" src="{:U('Admin/verify' )}" onclick="fleshVerify()" border="0" alt="点击刷新验证码" style="cursor:pointer" align="absmiddle" /> <span class="status"></span> </p>
    <p>
      <label></label>
      <input type="submit" value="登  陆" />
    </p>
  </fieldset>
</form>
</body>
</html>
